package org.black.phoneUtility.sms.reply.content.broadcastReceiver;

import org.black.phoneUtility.sms.reply.telephony.ReplyPhoneStateListener;

import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;

public class PhoneStateBroadcastReceiver extends BroadcastReceiver {
	private static final String LOG_TAG = PhoneStateBroadcastReceiver.class
			.getName();

	@Override
	public void onReceive(Context context, Intent intent) {
		Log.d(LOG_TAG, "Receive phone status change.");

		TelephonyManager telephonyManager = (TelephonyManager) context
				.getSystemService(Service.TELEPHONY_SERVICE);
		ReplyPhoneStateListener replyPhoneStateListener = new ReplyPhoneStateListener(
				context);
		telephonyManager.listen(replyPhoneStateListener,
				PhoneStateListener.LISTEN_CALL_STATE);
		telephonyManager.listen(replyPhoneStateListener,
				PhoneStateListener.LISTEN_NONE);
		telephonyManager = null;
	}

}
